package com.baomidou.mybatisplus.generator.config.converts;

import com.baomidou.mybatisplus.generator.config.ITypeConvert;
import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;

/**
 * <p>
 * description:
 * </p>
 *
 * @author ygf
 * @date 2017/9/3 10:40
 */
public class MySqlTypeConvert implements ITypeConvert {
    public MySqlTypeConvert() {
    }

    public DbColumnType processTypeConvert(String fieldType) {
        String t = fieldType.toLowerCase();
        return !t.contains("char") && !t.contains("text") ? (t.contains("bigint") ? DbColumnType.LONG : (t.contains("int") ? DbColumnType.INTEGER : (!t.contains("date") && !t.contains("time") && !t.contains("year") ? (t.contains("text") ? DbColumnType.VARCHAR : (t.contains("bit") ? DbColumnType.BOOLEAN : (t.contains("decimal") ? DbColumnType.BIG_DECIMAL : (t.contains("clob") ? DbColumnType.CLOB : (t.contains("blob") ? DbColumnType.BLOB : (t.contains("binary") ? DbColumnType.BYTE_ARRAY : (t.contains("float") ? DbColumnType.FLOAT : (t.contains("double") ? DbColumnType.DOUBLE : (!t.contains("json") && !t.contains("enum") ? DbColumnType.VARCHAR : DbColumnType.VARCHAR))))))))) : DbColumnType.DATE))) : DbColumnType.VARCHAR;
    }
}
